package com.shoujifeng.snowmusic.player.http;

import java.io.File;
import java.util.HashMap;

import android.content.Context;
import android.os.Environment;

public class GlobalValue
{
	public final static int USER_ID = 1;
	public final static float VERSION = 0.9f;
	
	public static Context mParentContext = null;
	
	private static HashMap<String, String> mUrlMap;
	
	public static HashMap<String, String> mSDAddrMap;
	public static final String IMAGE_PATH_NEWS = "ImagePathNews";
	
	public static String CacheFile = "/SnowMusic/Cache";
	public final static int PAGE = 0;
	
	public static DownloadManager g_DownloadManager;
	
	public static void addUrl(String key, String value)
	{
		if(mUrlMap == null)
			mUrlMap = new HashMap<String, String>();
		
		mUrlMap.put(key, value);
	}
	
	public static String getUrl(String key)
	{
		return mUrlMap.get(key).toString();
	}
	
	/**
	 * 初始化SD卡地址
	 */
	public static void initSDAddr()
	{
		String SDPathString = getSDcardPath();
		mSDAddrMap = new HashMap<String, String>();
		mSDAddrMap.put(IMAGE_PATH_NEWS, SDPathString + "/SGHome/Image/news/");
		
		createDir(mSDAddrMap.get(IMAGE_PATH_NEWS));
	}
	
	/**
	 * 获取Sd卡地址
	 * @param label
	 * @return
	 */
	public static String getSDAddr(String label)
	{
		return mSDAddrMap.get(label);
	}
	
	/**
	 * 得到Sd卡路径
	 * @return
	 */
	public static String getSDcardPath()
	{
		String pathString = "";
		boolean bHave = Environment.getExternalStorageState().equals(
				android.os.Environment.MEDIA_MOUNTED);

		if (bHave)
		{
			pathString = Environment.getExternalStorageDirectory().toString();
		}

		return pathString;
	}
	
	/**
	 * 创建文件夹
	 * @param pathString
	 */
	public static void createDir(String pathString)
	{
		File file = new File(pathString);
		if(!file.exists())
		{
			file.mkdirs();
		}

	}
}
